;*****************************************************************************************************
;+
; NAME:
;
;      eERASE (enhanced ERASE)
;
; PURPOSE:
;
;      This is the enhanced version of the standard IDL ERASE
;      command. It erases the contents of the current IGL window.
;
; CALLING SEQUENCE:
;
;      eERASE, background_color
;
; ARGUMENTS:
;
;     BACKGROUND_COLOR:  The name of the color to which the window will
;                        be erased. The default is !IGL_P.background
;                 
; KEYWORD PARAMETERS:
;
;     COLOR:             This is similar to the BACKGROUND_COLOR
;                        argument and is provided here for
;                        compatibility with the standard ERASE procedure.
;    
; PACKAGE:
;
;    Interactive Graphics Library (IGL)
;
; AUTHORS:
;
;        RAPHAEL SADOUN
;        Graduate Student
;        Institut d'Astrophysique de Paris
;        98 bis boulevard Arago
;        75014 PARIS FRANCE
;        E-mail: raphael.sadoun@gmail.com
;
;
; MODIFICATION HISTORY:
;
;     Written by: Raphael Sadoun, 24 April 2012
;-
;*****************************************************************************************************
PRO eERASE, background_color, COLOR=color

  COMPILE_OPT idl2, HIDDEN
  ON_ERROR, 2

  ;; Initialize the global system variables
  IGL_InitSysVars

  ;; Default keyword values
  IF N_ELEMENTS(background_color) EQ 0 THEN bgcolor = !IGL_P.background ELSE bgcolor = background_color
  IF N_ELEMENTS(color) EQ 0 THEN bgcolor = !IGL_P.background ELSE bgcolor = color

  ;; Get the current IGL window
  currentWindow = IGL_GetCurrentWindow()

  ;; Return silently if there is no window to erase
  IF OBJ_ISA_VALID(currentWindow,'IGL_Window') EQ 0 THEN RETURN

  ;; Set the window color to the erase color
  currentWindow -> SetProperty, window_color=bgcolor

  ;; Destroy all the graphics and refreshes window's content
  currentWindow -> ClearWindow

  ;; Refreshes the property editor
  currentWindow -> GetProperty, PropertyPanel=PropertyPanel
  IF OBJ_VALID(PropertyPanel) THEN PropertyPanel -> UpdateTreeBrowser

END
